﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ChoViet.Lib.Common;
using ChoViet.Model;
using ChoViet.CMS.ViewModels;

namespace ChoViet.CMS.Controllers
{
	[HandleError]
	public class HomeController : BaseController
	{
        ChoVietDataContext eDataContext = new ChoVietDataContext();

        #region CMS
        [Authorize()]
        public ActionResult IndexCms()
		{
            HomeViewModels h = new HomeViewModels();
            var isAdmin = UserManager.CheckRole(RoleSystem.Administrator);
            //int inOrganizationID = UserProfile.GetOrganizationID();
            //var l = eDataContext.Schedules.ToList();
            //h.Schedules = l;
			return View(h);
		}
        #endregion

		public ActionResult About()
		{
			return View();
		}

        public ActionResult Index()
        {
            //var param = new HomeSiteIndexViewModel();
            //param.Category = new Category();
            //param.Demand = new Demand();
            //param.City = new City();
            //param.AdAttribute = new AdAttribute();
            //param.AdAttributeValue = new AdAttributeValue();
            //param.CusTypeId = new int();
            //param.TotalVisited = new int();
            //return View(param);
            HomeViewModels h = new HomeViewModels();
            var isAdmin = UserManager.CheckRole(RoleSystem.Administrator);
            //int inOrganizationID = UserProfile.GetOrganizationID();
            //var l = eDataContext.Schedules.ToList();
            //h.Schedules = l;
            return View(h);
        }

        public ActionResult Usermanage()
        {
            return View();
        }

        public ActionResult Introduction()
        {
            return View();
        }

        public ActionResult Regulations()
        {
            return View();
        }

        public ActionResult Postnews()
        {
            return View();
        }

        public ActionResult Feedback()
        {
            return View();
        }

        public ActionResult Contact()
        {
            return View();
        }

        [ChildActionOnly]
        public ActionResult Visited()
        {
            CounterViewModels c = new CounterViewModels();
            //c.TotalVisited = eDataContext.Counters.Sum(e => e.Visited).Value;
            //var y = eDataContext.Counters.Where(a => a.AddDate.Value.Day == DateTime.Now.AddDays(-1).Day &&
            //        a.AddDate.Value.Month == DateTime.Now.Month &&
            //        a.AddDate.Value.Year == DateTime.Now.Year).FirstOrDefault();
            //c.Yesterday = y != null ? y.Visited : 0;
            return View(c);
        }

	}
}
